import uuid

from CloudEngine.core.VTActor import VTActor
from Connector.client import res_success


class CmdActorColorReset:
    name = "cmd_actor_color_reset"
    id = uuid.uuid4()

    def __init__(self, service, Params, Tag, Type):
        self.service = service
        self.params = Params
        self.tag = Tag
        self.type = Type

    async def execute(self):
        uid = self.params.get("uid", None)
        if not uid:
            actor_list = self.service.app.actorList.value()
            if len(actor_list) > 0:
                ac: VTActor = actor_list[0]
                ac.reset_cell_color()
                self.service.app.remove_scalar_bar(ac.scalar_bar.instance)
                self.service.app.state.to_normal()
                self.service.app.render()
        await res_success(self.tag, self.type, {})
